{template header}


<style>
    .wish-show-content{}
    .wish-show-content img{max-width: 100%;}
</style>

<div class="container">



<div class="row">


<div class="col-md-8">









    <div class="panel panel-default">
        <div class="panel-body">


            <div class="page-header">
                <h1>{$strWish[title]}                     <small>

                </small></h1>
            </div>





            <div class="row">
                <div class="col-md-6"><img style="width:100%;" title="点击看大图" src="{if $strWish[photo]}{php echo tsXimg($strWish[photo],'wish',500,'',$strWish[path])}{else}{SITE_URL}app/wish/skins/default/wish.jpg{/if}" /></div>
                <div class="col-md-6">



                    <div class="c9 f12" style="line-height: 25px">

                        发布人： <a href="{tsUrl('user','duty',array('id'=>$strWish[user][userid]))}">{$strWish[user][username]}</a> <br/>
                        心愿主人： {$strWish[wisher]} <br/>
                        所在单位：<a href="{$strWish[group][link]}"> {$strWish[group][groupname]}</a><br/>
                        {if $strWish['grade']&&$strWish['clasee']}
                        所在班级：{php echo changeNum($strWish[grade])}年级{$strWish[class]}班<br/>
                        {/if}
                        心愿类型： <a href="{tsUrl('wish','type',array('id'=>$strWish['type']['typeid']))}">{$strWish[type][typename]}</a><br/>
                        心愿数：{$strWish['quota']}<br/>
                        认领期限： {php echo date('Y-m-d H:i',$strWish[limittime])}<br/>
                        {if $strWish['link']}
                        参考链接：点击<a href="{$strWish['link']}">这里</a><br/>
                        {/if}
                        收货地点：<strong style="color: black">{$strWish[group][province]}{$strWish[group][city]}{$strWish[group][address]}</strong> <br/>
                        {if $strWishUser}
                        收货人：<strong style="color: black">{$strWish[contact]}&nbsp;&nbsp;{$strWish[phone]}</strong><br/>
                        {/if}
                        认领数：{$strWish[count_userwish]}<br/>
                        达成数：{$strWish[count_userdo]}<br/>
                        点赞数：{$strWish[count_recommend]}<br/>
                    </div>



                    <div class="tar">
                        {if $TS_USER[userid]&&$strWish[userid]!=$TS_USER[userid]}
                        <a class="pull-right" style="margin-left: 5px" href="javascript:void('0');" onclick="recommend({$strWish[wishid]})">{if $isRecommend==0}<i class="fa fa-heart-o"></i> 赞{else}<i class="fa fa-heart"></i> 取消{/if}</a>
                        {/if}


                        {if $strWish[limittime]<=time()}
                        认领已截止
                        {else}
                            {if $strWishUser}
                                {if $strWishUser['status']== 0 }
                                     <a class="btn btn-default" href="javascript:void('0');" onclick="cancelWish('{$strWish[wishid]}')"> 我放弃</a>
                                {/if}
                            {else}
                                   {if $strWish['quota']==$strWish['count_userwish']}
                                        已认领完毕
                                    {else}
                                         <a class="btn btn-success" data-toggle="modal" data-target="#do_wish_form">我认领</a>


                                    {/if}
                            {/if}
                        {/if}


                    </div>




                </div>
            </div>












</div>

</div>









    <div class="panel panel-default">
        <div class="panel-heading">心愿详情</div>
        <div class="panel-body">
            <div class="wish-content">
                <div class="wish-view">

                    <p>{$strWish[content]}</p>
                </div>
            </div>
<div style="text-align:right;">
{if $GLOBALS[TS_USER][userid] == $strWish[userid] || $GLOBALS[TS_USER][isadmin]=='1'}
<a href="{tsUrl('wish','edit',array('ts'=>'base','wishid'=>$strWish['wishid']))}">修改</a>
    &nbsp;&nbsp;<a href="{SITE_URL}index.php?app=wish&ac=delete&ts=base&wishid={$strWish[wishid]}&token={$_SESSION['token']}"  onClick="return confirm('确定删除吗?')">删除</a>
{/if}
</div>

</div>
</div>




    <div class="panel panel-default">
        <div class="panel-heading">{if $GLOBALS[TS_USER][userid] == $strWish[userid] || $GLOBALS[TS_USER][isadmin]=='1'}<a href="{tsUrl('wish','edit',array('ts'=>'join','wishid'=>$wishid))}">{/if}认领的人{if $GLOBALS[TS_USER][userid] == $strWish[userid] || $GLOBALS[TS_USER][isadmin]=='1'}</a>{/if} <small>(合计认领{$strWish[count_userwish]}份，名字橙色表示已认领，蓝色表示已发货，绿色表示已收货)</small></div>
        <div class="panel-body">



            <div class="facelist">
                <ul>
                {loop $arrDoUser $key $item}
                <li>
                    <a href="{tsUrl('user','duty',array('id'=>$item[userid]))}">
                        <img class="img-circle" src="{$item['user'][face]}" alt="{$item['user']['username']}"  width="48" height="48" />
                    </a>
                    <div class="username">

                        {if $item['status']<2}
                        <a {if $GLOBALS[TS_USER][userid] == $strWish[userid] || $GLOBALS[TS_USER][isadmin]=='1'}href="javascript:void('0');" onclick="attendWish({$strWish[wishid]},{$item['userid']})"{/if} style="color:{if $item['status']==0}orange{else}blue{/if}">{$item['user']['username']}({$item[quota]})</a>
                        {else}
                        <a {if $GLOBALS[TS_USER][userid] == $strWish[userid] || $GLOBALS[TS_USER][isadmin]=='1'}href="javascript:void('0');" onclick="absentWish({$strWish[wishid]},{$item['userid']})"{/if} style="color: green">{$item['user']['username']}({$item[quota]})</a>
                        {/if}

                    </div>
                </li>
                {/loop}
                </ul>
            </div>
</div>
</div>


    <div class="panel panel-default">
        <div class="panel-heading">你的回应</div>
        <div class="panel-body">

            <div class="comment">

<ul>

{loop $arrComment $key $item}
<li class="clearfix">
    <div class="user-face">
        <a href="{tsUrl('user','duty',array('id'=>$item[user][userid]))}"><img title="{$item[user][username]}" alt="{$item[user][username]}" src="{$item[user][face]}" class="pil img-circle" width="48" height="48" /></a>
    </div>
    <div class="reply-doc">
            <h4>{php echo date('Y-m-d H:i:s',$item[addtime])}
                <a href="{tsUrl('user','topic',array('id'=>$item[userid]))}">{$item[user][username]}</a>
            </h4>
        <p>{$item[content]}</p>
	
	   {if $GLOBALS[TS_USER][userid] == $strWish[userid] || $GLOBALS[TS_USER][isadmin]=='1'}
        <div class="group_banned">
            <span><a class="j a_confirm_link" onclick="return confirm('确定删除?')" href="{SITE_URL}index.php?app=wish&ac=delete&ts=comment&wishid={$strWish['wishid']}&commentid={$item['commentid']}">删除</a>
            </span>
        </div>
	{/if}
	
    </div>
</li>
{/loop}
</ul>

            </div>

<div class="page">{$pageUrl}</div>

{if $GLOBALS[TS_USER][userid] == ''}
<div style="font-size:14px;padding:40px 0;text-align:center;">请登录后回应本心愿^_^</div>
{else}
<div>
<form method="POST" action="{tsUrl('wish','comment')}" onSubmit="return submitonce(this)"  id="formMini">
    <div class="wangeditor_toolbar" id="tseditor"></div>
    <div class="wangeditor_text" id="tseditor2"></div>
    <div style="display: none"><textarea id="content" name="content"></textarea></div>
<input type="hidden" name="wishid" value="{$strWish[wishid]}" />
<input class="btn btn-success" type="submit" value="发表回复">
</form>
</div>
{/if}

</div>

</div>


</div>


<div class="col-md-4">




    <div class="panel panel-default">
        <div class="panel-body">
<a href="{tsUrl('wish','type',array(id=>$strWish[type][typeid]))}">更多{$strWish[type][typename]}心愿</a>
</div>
</div>





{if $strWish['coordinate']}

    <div id="container" style="width:100%;height:300px;"></div>

    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=dbf1281241fe7a7a9c04b486e1a31651"></script>
    <script type="text/javascript">
        //初始化地图对象，加载地图
        var map = new AMap.Map("container", {
            resizeEnable: true,
            center: [{$strWish['coordinate']}],//地图中心点
            zoom: 13 //地图显示的缩放级别
        });
        //添加点标记，并使用自己的icon
        new AMap.Marker({
            map: map,
            position: [{$strWish['coordinate']}],
            icon: new AMap.Icon({
                size: new AMap.Size(40, 50),  //图标大小
                image: "http://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png",
                imageOffset: new AMap.Pixel(0, -60)
            })
        });
    </script>

    {/if}




    <!--广告位-->
    {php doAction('gobad','300')}


</div>


</div>
</div>


<div id="do_wish_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">认领心愿</h5>
            </div>
            <div class="modal-body" >
<form  id="join_form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=wish&ac=do&ts=join">
    <div class="form-group">

        <div class="col-sm-12">
            <div class="content">{$strTopic['content']}</div>
        </div>
    </div>
  <div class="form-group">
    <label class="col-sm-2 control-label">姓名</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="username" name="username">
    </div>
  </div>

   <div class="form-group">
    <label class="col-sm-2 control-label">手机</label>
    <div class="col-sm-10">
        <input type="text" class="form-control" id="phone" name="phone" value="{$GLOBALS[TS_USER][phone]}">
    </div>
  </div>


    <div class="form-group">
        <label class="col-sm-2 control-label">数量</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="quota" name="quota" value="{$remain}">
        </div>
    </div>


  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
	
	<input type="hidden" id="wishid" name="wishid" value="{$strWish['wishid']}" />
	
      <button type="submit" class="btn btn-success">点击提交</button>
    </div>
  </div>
</form>

            </div>
        </div>
    </div>
</div>



<script>

    $(function(){
        $('#formMini').on('submit', function(e) {

            var content  = $('#content').val();

            if(content == '<p><br></p>'){
                bootbox.alert('内容不能为空');
                return false;
            }

        });

    });

    $(function(){
        $('#kuaidi').on('submit', function(e) {
            var corp  = $('#corp').val();
            var number  = $('#number').val();
            if(corp == ''){
                bootbox.alert('快递公司必填');
                return false;
            }
            if(number == ''){
                bootbox.alert('单号必填');
                return false;
            }
        });

    });

    $(function(e){
        $('#join_form').on('submit', function(e) {
            var wishid  = $('#wishid').val();
            var username  = $('#username').val();
            var phone = $('#phone').val();
            var quota  = $('#quota').val();
            var iszhengshu = $('#iszhengshu').val();


            if(username==''){
                bootbox.alert('姓名必填');
                return false;
            }

            if(phone==''){
                bootbox.alert('手机必填');
                return false;
            }

            if(quota==''){
                bootbox.alert('数量必填');
                return false;
            }


        });

    });




    //确认收货
    function attendWish(wishid,userid){


        if (confirm('确定此人已履约帮助小读者达成心愿了吗？')) {

            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=wish&ac=do&ts=attend",
                data: "wishid="+wishid+"&memberid="+userid,
                beforeSend:function(){
                },
                success:function(result){
                        window.location.reload();
                }
            });

        }
    }

    //确认缺席
    function absentWish(wishid,userid){


        if (confirm('确定此人爽约了吗？')) {

            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=wish&ac=do&ts=absent",
                data: "wishid="+wishid+"&memberid="+userid,
                beforeSend:function(){
                },
                success:function(result){
                        window.location.reload();
                }
            });

        }
    }

    function kuaidi(){
        $('#protocol').modal('hide');
        $('#kuaidi').modal('show');
    }

</script>

{if $strWishUser&&$strWishUser['status']==0}
<div id="protocol" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"   style="overflow:scroll;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">心愿认领成功</h5>
            </div>
            <div class="modal-body" >

                <div class="form-group">
                    {$notice}
                </div>
                <div class="form-group">
                    收货地点: {$strWish[group][province]}{$strWish[group][city]}{$strWish[group][address]}<br/>
                    收货人：{$strWish[contact]}&nbsp;&nbsp;{$strWish[phone]}<br/>
                </div>
                <div class="form-group">
                    <center><a class="btn btn-default" onclick="kuaidi()" >填写物流信息</a>&nbsp;&nbsp;<a class="btn btn-default" onclick="closeit()" >我知道了</a></center>
                </div>

            </div>
        </div>
    </div>
</div>


<div id="kuaidi" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">请填写物流信息</h5>
            </div>
            <form  id="join_form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=wish&ac=comment">

                <div class="modal-body">
                <div class="form-group">
                    <label class="col-sm-2 control-label">快递公司</label>
                    <div class="col-sm-10">

                        <select id="corp" name="corp">
                            <option value=""></option>
                            <option value="顺丰">顺丰</option>
                            <option value="中通">中通</option>
                            <option value="圆通">圆通</option>
                            <option value="韵达">韵达</option>
                            <option value="申通">申通</option>
                            <option value="京东">京东</option>
                            <option value="EMS">EMS</option>
                            <option value="百世">百世</option>
                            <option value="联邦">联邦</option>
                            <option value="自送">自送</option>
                        </select>
                    </div>

                </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">单号</label>
                        <div class="col-sm-10">
                            <input  type="text" class="form-control" id="number" name="number" placeholder="单号">
                        </div>
                    </div>
                <div class="form-group">
                    <input type="hidden" name="wishid" value="{$strWish[wishid]}" />
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-success">点击提交</button>
                    </div>

                </div>

            </div>
                </form>
        </div>
    </div>
</div>

<script>
    $('#protocol').modal('show');

    function closeit(){
        $('#protocol').modal('hide');
    }
</script>

{/if}


{if $GLOBALS[TS_USER][userid] == $strWish[userid]&&$strWish[count_userwish]>0&&$strWish[count_userdo]<$strWish[count_userwish]}
<div id="wishuser_notice" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">认领人信息</h5>
            </div>

            <div class="modal-body" >
                <div class="form-group">
                    {loop $arrDoUser $key $item}
                    <div>{$item['user']['username']}</div>
                    <div>{$item['user']['phone']}</div>
                    <div>认领数：{$item['quota']}</div>
                    <div>截止日期：{php echo date('Y-m-d H:i:s',$item['limittime'])}</div>
                    <br/>
                    {/loop}
                </div>
                <div class="form-group">
                    如果已经收货，请及时在页面左下方认领区点击认领人<strong>姓名</strong>（不是头像），确认收货；<br/>
                    如果认领人爽约，请点击认领区“<a href="{tsUrl('wish','edit',array('ts'=>'join','wishid'=>$wishid))}">认领的人</a>”链接，打开认领名单，点击“开除”按钮取消认领资格。<br/>
                </div>

            </div>
        </div>
    </div>
</div>

<script>
    $('#wishuser_notice').modal('show');
</script>

{/if}
{php doAction('tseditor','mini')}
{template footer}